<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="vue3.0项目, 木心">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>vue3.0项目 | 木心</title>
    <link rel="icon" type="image/jpeg" href="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/medias/avatar.jpg">

    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/css/my.css">

    <script src="/zheng_jinhao/libs/jquery/jquery.min.js"></script>

<style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }
    
    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }
    
   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}
    
    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}
    
   
    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script><meta name="generator" content="Hexo 4.2.1"><link rel="stylesheet" href="/zheng_jinhao/css/prism-shades-of-purple.css" type="text/css">
<link rel="stylesheet" href="/zheng_jinhao/css/prism-line-numbers.css" type="text/css"><style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }
    
    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }
    
   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}
    
    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}
    
   
    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script></head>


<!-- 样式二（飘动的彩带） -->
<!-- <script src="https://g.joyinshare.com/hc/piao.js" type="text/javascript"></script> -->

 <div id="loading-container">
     <p class="loading-text">玩命加载中 . . . </p> 
     <div class="loading-image">
         <div></div>
         <div></div>
         <div></div>
         <div></div> 
         <div></div>
     </div>
 </div><body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/zheng_jinhao/" class="waves-effect waves-light">
                    <div>
                        
                        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/medias/logo1.gif" class="logo-img" alt="LOGO">
                        
                        <span class="logo-span">木心</span>
                    </div>
                </a>
            </div>
           
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/about" class="waves-effect waves-light">
      
      <i class="fas fa-address-card" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/zheng_jinhao/navigate" class="waves-effect waves-light">
      
      <i class="fas fa-location-arrow" style="zoom: 0.6;"></i>
      
      <span>快捷导航</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/medias/logo1.gif" class="logo-img circle responsive-img">
        
        <div class="logo-name">木心</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-card"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/zheng_jinhao/navigate" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-location-arrow"></i>
			
			快捷导航
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn//medias/featureimages/1.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">vue3.0项目</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/zheng_jinhao/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }
    

    .toc-widget {
        width: 345px;
        padding-left: 20px;
        background-color: rgb(255, 255, 255,0.7);
        border-radius: 10px;
        box-shadow: 0 10px 35px 2px rgba(0, 0, 0, .15), 0 5px 15px rgba(0, 0, 0, .07), 0 2px 5px -5px rgba(0, 0, 0, .1) !important;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/zheng_jinhao/tags/vue/">
                                <span class="chip bg-color">vue</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/zheng_jinhao/categories/%E9%A1%B9%E7%9B%AE/" class="post-category">
                                项目
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-08-07
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2020-08-23
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.3k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    21 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="万年历项目"><a href="#万年历项目" class="headerlink" title="万年历项目"></a>万年历项目</h1><h2 id="请求数据"><a href="#请求数据" class="headerlink" title="请求数据"></a>请求数据</h2><h4 id="请求数据接口会遇到跨域问题就先把接口进行代理"><a href="#请求数据接口会遇到跨域问题就先把接口进行代理" class="headerlink" title="请求数据接口会遇到跨域问题就先把接口进行代理"></a>请求数据接口会遇到跨域问题就先把接口进行代理</h4><p>新建vue.config.js</p>
<pre><code>module.exports = {
devServer: {
    proxy:{
        &quot;/api&quot; : {
            target: &#39;http://web.juhe.cn:8080/&#39;,
            changeOrigin: true,
            ws: true,
            secure: false,
            pathRewrite: {
                &#39;^/api&#39;: &#39;&#39;
            }
        }
    }
},
    lintOnSave : false
}</code></pre><p>安装 npm i - S axios qs</p>
<p>先整理下代码目录结构</p>
<p>路由配置 ，根目录下导入组件其他的用动态加载</p>
<pre><code>import TodayPage from &#39;@/views/Today&#39;

const routes = [
  {
    path: &#39;/&#39;,
    name: &#39;today&#39;,
    component: TodayPage

  },
  {
    path: &#39;/tomorrow&#39;,
    name: &#39;tomorrow&#39;,
    component: ()=&gt; import(&#39;../views/Tomorrow&#39;)

  },
  {
    path: &#39;/week&#39;,
    name: &#39;week&#39;,
    component: import(&#39;../views/Week&#39;)

  },
  {
    path: &#39;/tomonth&#39;,
    name: &#39;tomonth&#39;,
    component: import(&#39;../views/Tomonth&#39;)

  },
  {
    path: &#39;/year&#39;,
    name: &#39;year&#39;,
    component: import(&#39;../views/Year&#39;)

  },

]</code></pre><pre><code>&lt;template&gt;
  &lt;div class=&quot;container&quot;&gt;
      Today
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
    name: &#39;TodayPage&#39;

}
&lt;/script&gt;

&lt;style lang=&#39;scss&#39; scoped&gt;

&lt;/style&gt;</code></pre><p>实现router单页面跳转</p>
<h3 id="封装接口数据"><a href="#封装接口数据" class="headerlink" title="封装接口数据"></a>封装接口数据</h3><p>可以将这个接口分成三部分便于管理</p>
<p><a href="http://web.juhe.cn:8080/constellation/getAll?consName=%E7%8B%AE%E5%AD%90%E5%BA%A7&amp;type=week&amp;key=93b2161540c9f2af182c2e4082d4333d]" target="_blank" rel="noopener">http://web.juhe.cn:8080/constellation/getAll?consName=%E7%8B%AE%E5%AD%90%E5%BA%A7&amp;type=week&amp;key=93b2161540c9f2af182c2e4082d4333d]</a>(<a href="http://web.juhe.cn:8080/constellation/getAll?consName=狮子座&amp;type=week&amp;key=93b2161540c9f2af182c2e4082d4333d）" target="_blank" rel="noopener">http://web.juhe.cn:8080/constellation/getAll?consName=狮子座&amp;type=week&amp;key=93b2161540c9f2af182c2e4082d4333d）</a></p>
<p><a href="http://web.juhe.cn:8080/" target="_blank" rel="noopener">http://web.juhe.cn:8080/</a> 80端口可能端口号会不一样会出现跨域问题先进行代理上面已经执行</p>
<p>constellation/getAll?consName=%E7%8B%AE%E5%AD%90%E5%BA%A7&amp;type=week&amp;key=93b2161540c9f2af182c2e4082d4333d  consName其实是输入的星座  type是输入的日期可以单独分离出来，便于不要把数据写死 至于key也是单独放在keys.js里面</p>
<p>首页对于axios请求进行封装</p>
<pre><code>import axios from &#39;axios&#39;;

import {JUHE_APPKEY} from &#39;@/configs/keys&#39;;

function axiosGet(options){
    axios(options.url + &quot;&amp;key=&quot; + JUHE_APPKEY)
    .then((res)=&gt;{
        options.success(res);
        // console.log(res);
    })
    .catch((err)=&gt;{
        options.error(err)
    });
}

export {
    axiosGet,
}</code></pre><p>把axiosGet方法导入request.js进行处理 导出getData</p>
<pre><code>import { axiosGet } from &#39;@/libs/http&#39;;

function getData(consName, type) {
  return new Promise((resolve, reject) =&gt; {
    axiosGet({
      url: `/api/constellation/getAll?consName=${consName}&amp;type=${type}`,
      success(data) {
        resolve(data);
        // console.log(data);
      },
      error(error) {
        reject(error);
      },
    });
  });
}
export {
    getData
}</code></pre><p>再将getData方法给进行异步操作</p>
<pre><code>import {getData} from &#39;./request&#39;

export default async(store) =&gt; {
const consName = store.state.consName,
      field = store.state.field,
      data = await getData(consName,field);
    //   console.log(data);
    console.log(data);


}</code></pre><p>到这里data已经成功拿到数据 consName field 分别是放在state.js里面的默认数据，如果进行修改对应的页面也会进行修改然后去我们要展示的视图层</p>
<h3 id="视图请求数据"><a href="#视图请求数据" class="headerlink" title="视图请求数据"></a>视图请求数据</h3><pre><code>import { onMounted } from &#39;vue&#39;;

import { useStore } from &#39;vuex&#39;;
import getData from &#39;@/services&#39;;

export default {
    name: &#39;TodayPage&#39;,
    setup(){
      //可以拿到state数据
      const store = useStore();

      onMounted(()=&gt;{
        getData(store);
        // console.log( getData(store));

      })

    }

}</code></pre><p>vuex里面的useStore可以拿到data数据  getData（store）是将useStore拿到数据放进去 相当于getDate(‘水瓶座’，‘day’) 就会替换掉${consName} ,${type}的值。就可以做到动态修改到这里就基本实现router单页面跳转以及将数据对象获取到对应视图上监听路由改变就会修改对应的consName进而得到对应的接口数据</p>
<h2 id="day日期页面"><a href="#day日期页面" class="headerlink" title="day日期页面"></a>day日期页面</h2><p>首先实现day视图</p>
<p>头部和底部 观察发现每个视图都有所以将其挂载到App上(样式略)</p>
<h3 id="header"><a href="#header" class="headerlink" title="header"></a>header</h3><pre><code>&lt;template&gt;
  &lt;div&gt;
      &lt;header class=&quot;header&quot;&gt;
          &lt;img src=&quot;../../assets/img/cons.png&quot; alt=&quot;&quot;/&gt;
          &lt;h1&gt;
             &lt;slot&gt;&lt;/slot&gt; 
          &lt;/h1&gt;
      &lt;/header&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
    name: &#39;MyHeader&#39;

}
&lt;/script&gt;</code></pre><p>App.js</p>
<pre><code>  &lt;my-header&gt;星座物语&lt;/my-header&gt;
import MyHeader from &#39;@/components/Header&#39;;

 components: {
    MyHeader,
  },
</code></pre><h3 id="底部-tab"><a href="#底部-tab" class="headerlink" title="底部 tab"></a>底部 tab</h3><p>先外部先把数据加载好放在 tab.js</p>
<pre><code>export default [
{
    iconText: &#39;今&#39;,
    tabText: &#39;今天&#39;,
    path: &#39;/&#39;,
},
{
    iconText: &#39;明&#39;,
    tabText: &#39;明天&#39;,
    path: &#39;/Tomorrow&#39;,
},
{
    iconText: &#39;周&#39;,
    tabText: &#39;本周&#39;,
    path: &#39;/Week&#39;,
},
{
    iconText: &#39;月&#39;,
    tabText: &#39;本月&#39;,
    path: &#39;/month&#39;,
},
{
    iconText: &#39;年&#39;,
    tabText: &#39;本年&#39;,
    path: &#39;/year&#39;,
},

]</code></pre><p> 然后在 tab下的index里面放</p>
<pre><code>&lt;template&gt;
  &lt;div class=&quot;tab&quot;&gt;
      &lt;div
      class=&quot;tab-item&quot;
      v-for=&quot;(item,index) of tabData&quot;
      :key = &#39;index&#39;
      &gt;
      &lt;tab-icon
      :iconText = &#39;item.iconText&#39;
      :path = &#39;item.path&#39;
      &gt;
        {{item.tabText}}
      &lt;/tab-icon&gt;

      &lt;/div&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;

import TabIcon from &#39;./icon&#39;
import tabData from &#39;@/data/tab&#39;

import { reactive } from &#39;vue&#39;

export default {
    name: &#39;TabItem&#39;,
    components:{
        TabIcon,
    },
   setup(){
       const state = reactive({
           tabData
       });
       return{
           ...state
       }
   } 

}
&lt;/script&gt;</code></pre><p>这里涉及到的知识点是 reactive作用是将数据响应式显示 导入tab组件的数组tabData需要将其解构出来。 vue3用了什么数据都要进行返回 return … 是对其解构分开出来 然后在组件中 v-for=”(item,index) of tabData “进行循环 这里 of是循环数据的 in才是循环对象 item是值 index是索引 key绑定索引 然后把子组件传递出去到父组件 icon中</p>
<pre><code>&lt;template&gt;
  &lt;router-link :to=&#39;path&#39; class=&#39;tab-icon&#39;&gt;
  &lt;i class=&quot;icon&quot;&gt;{{iconText}} &lt;/i&gt;
  &lt;p class=&quot;text&quot;&gt;
      &lt;slot&gt;{{tabText}} &lt;/slot&gt;
  &lt;/p&gt;

  &lt;/router-link&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  name: &#39;TabIcon&#39;,
  props: {
    iconText: String,
    path: String
  }
}
&lt;/script&gt;
</code></pre><p>除了tab底部菜单栏还有input输入框三给页面都需要所以将其放在app组件上暂时不用那么复杂先 创建子组件然后子组件通过操作仓库的值对其赋值再通过watch进行侦听</p>
<pre><code>  watch(()=&gt;{
    console.log(router);
  return router.currentRoute.value.name;

  },(value)=&gt;{
    store.commit(&#39;setHeaderTitle&#39;,value);
    store.commit(&quot;setPlacecholder&quot;,value);
    store.commit(&#39;setMaxlength&#39;, value);
    store.commit(&#39;setField&#39;, value);
    store.commit(&#39;setErrorCode&#39;, 0);

  })</code></pre><p>一旦数据发生改变就会触发commit进行方法触发状态修改 就可以把需要的值进行修改了</p>
<h3 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h3><p>这里补充一点通过<code>router.push(&#39;/&#39;);</code> 可以让每次刷新页面界面可以回到首页 还有通过</p>
<pre><code>      &lt;router-view v-slot=&quot;{ Component}&quot;&gt;
         &lt;keep-alive&gt;
           &lt;component :is=&quot;Component&quot;/&gt;
         &lt;/keep-alive&gt;
       &lt;/router-view&gt;</code></pre><p>将请求数据暂时放在缓冲区，不会每次切换页面都进行数据请求</p>
<pre><code>  &lt;input type=&quot;text&quot;
    :placeholder=&quot;placeholder&quot;
    :maxlength=&quot;maxlength&quot;
    :value=&quot;inputValue&quot;
    @input=&quot;searchData($event)&quot;
    &gt;</code></pre><h3 id="父子组件传值"><a href="#父子组件传值" class="headerlink" title="父子组件传值"></a>父子组件传值</h3><p>父组件这些值怎么传进去呢，通过const router = useRouter(); 观察发现每次切换页面router的currentRoute.value携带的我们想要的值然后</p>
<p>然后挂载到 app.js上 到这里就基本实现单页面tab切换，整体架构搭建完毕</p>
<p>day.vue页面的编写 首先新建组件</p>
<pre class="line-numbers language-javascript"><code class="language-javascript"><span class="token operator">&lt;</span>template<span class="token operator">></span>
  <span class="token operator">&lt;</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"contaniner"</span><span class="token operator">></span>
    <span class="token operator">&lt;</span>day<span class="token operator">-</span>card <span class="token punctuation">:</span>data <span class="token operator">=</span><span class="token string">"dayData"</span><span class="token operator">></span><span class="token operator">&lt;</span><span class="token operator">/</span>day<span class="token operator">-</span>card<span class="token operator">></span>
   <span class="token operator">&lt;</span><span class="token operator">!</span><span class="token operator">--</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>dayData<span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token operator">--</span><span class="token operator">></span>
    <span class="token operator">&lt;</span>day<span class="token operator">-</span>list <span class="token punctuation">:</span>data<span class="token operator">=</span><span class="token string">"dayData"</span><span class="token operator">/</span><span class="token operator">></span>
  <span class="token operator">&lt;</span><span class="token operator">/</span>div<span class="token operator">></span>

<span class="token operator">&lt;</span><span class="token operator">/</span>template<span class="token operator">></span>

<span class="token operator">&lt;</span>script<span class="token operator">></span>

<span class="token keyword">import</span> getData <span class="token keyword">from</span> <span class="token string">'@/services'</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> onMounted<span class="token punctuation">,</span> computed<span class="token punctuation">,</span>watch  <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'vue'</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> useStore <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'vuex'</span>

<span class="token keyword">import</span> DayCard <span class="token keyword">from</span> <span class="token string">'@/components/DayPage/Card'</span>
<span class="token keyword">import</span> DayList <span class="token keyword">from</span> <span class="token string">'@/components/DayPage/List/Lists'</span>

<span class="token keyword">import</span> <span class="token punctuation">{</span>getNowDate<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">"@/libs/utils"</span>


<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
    name<span class="token punctuation">:</span> <span class="token string">'DaPage'</span><span class="token punctuation">,</span>

    components<span class="token punctuation">:</span><span class="token punctuation">{</span>
       DayCard<span class="token punctuation">,</span>
      DayList<span class="token punctuation">,</span>

    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">const</span> store <span class="token operator">=</span> <span class="token function">useStore</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          state <span class="token operator">=</span> store<span class="token punctuation">.</span>state<span class="token punctuation">;</span>
        console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span><span class="token punctuation">;</span>

    watch <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> state<span class="token punctuation">.</span>dayData
      <span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">></span><span class="token punctuation">{</span>
        store<span class="token punctuation">.</span>commit <span class="token punctuation">(</span><span class="token string">'setErrorCode'</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

      <span class="token punctuation">}</span><span class="token punctuation">)</span>

    <span class="token function">onMounted</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">></span><span class="token punctuation">{</span>
      <span class="token function">getData</span><span class="token punctuation">(</span>store<span class="token punctuation">,</span><span class="token string">'day'</span><span class="token punctuation">,</span> <span class="token function">getNowDate</span><span class="token punctuation">(</span><span class="token string">'day'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment" spellcheck="true">// console.log(computed(()=> state.dayData).value);</span>
      <span class="token keyword">return</span> <span class="token punctuation">{</span>
        dayData<span class="token punctuation">:</span> <span class="token function">computed</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">></span> state<span class="token punctuation">.</span>dayData<span class="token punctuation">)</span><span class="token punctuation">,</span>
        errorCode<span class="token punctuation">:</span> <span class="token function">computed</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">></span>state<span class="token punctuation">.</span>errorCode<span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">}</span>

  <span class="token punctuation">}</span>

<span class="token punctuation">}</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">></span>

<span class="token operator">&lt;</span>style<span class="token operator">></span>

<span class="token operator">&lt;</span><span class="token operator">/</span>style<span class="token operator">></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>利用组件化思想，导入组件DayCard DayList 然后通过父子传值 ：data=“dayData”传进去</p>
<p>这里我们要获取dayData的值要利用computed属性 通过return dayData: computed(()=&gt; state.dayData), 这里需要调用到仓库的值所以再导入 const store = useStore() 然后到这一步再想怎么利用store里面的state的参数进行值的修改 在state里面新建data={} 然后在mutation进行 setData(state,data){data=state.data} 仓库和方法写好后在哪拿到值呢，就是请求属性的promise成功放回的data  但是要用到仓库store所以再传参的时候要加进来然后就可以 <em>store</em>.commit(‘setData’,{  field,  data: res }) 这里传field是因为案例需要三个data分别存放day month year 所以前面代码应该改成</p>
<p>state</p>
<pre><code>export default {
    dayData: {},
    monthData: [],
    yearData: [],
    field: &#39;day&#39;

}</code></pre><pre><code>setData (state,payload){
  const {field, data} = payload;
  switch (field){
    case &#39;day&#39;:
      state.dayData = data;
      break;
    case &#39;month&#39;:
      state.monthData = data;
      break;
      case &#39;year&#39;:
        state.yearData = data;
        break;
      default:
        break;  
  }</code></pre><pre><code> store.commit(&#39;setData&#39;,{
    field,
    data: res
  })</code></pre><h3 id="getNowDate-工具函数"><a href="#getNowDate-工具函数" class="headerlink" title="getNowDate()工具函数"></a>getNowDate()工具函数</h3><p>再通过组件挂载调用它即可 这里涉及到一个工具函数处理用户输入的20200616值改变成功接口参数2020-6-16 getNowDate()</p>
<pre><code>function getNowDate(field) {
  const date = new Date();
  let year = date.getFullYear(),
    month = date.getMonth() + 1,
    day = date.getDate();

  switch (field) {
    case &quot;day&quot;:
      return `${year}-${month}-${day}`;
    case &quot;month&quot;:
      return `${year}-${month}`;
    case &quot;year&quot;:
      return `${year}`;
    default:
      return `${year}-${month}-${day}`;
  }
}</code></pre><pre><code> onMounted(()=&gt;{
      getData(store,&#39;day&#39;, getNowDate(&#39;day&#39;));
    });</code></pre><h3 id="拿到data数据"><a href="#拿到data数据" class="headerlink" title="拿到data数据"></a>拿到data数据</h3><p>然后就data数据怎么拿到的呢就是通过 封装stetData函数接受三个参数先封装后面几个请求方法</p>
<pre><code>import {axiosPost} from &#39;@/libs/http&#39;;
function getDayData(date){
 return new Promise((resolve,reject)=&gt;{
    axiosPost({
        url: &#39;/api/calendar/day&#39;,
        data:{date},
        success(data){
            resolve(data)
        },
        error(err){
            reject(err)
        }
    });
 });

}

function getMonthData(yearMonth){
    return new Promise((resolve,reject)=&gt;{
       axiosPost({
           url: &#39;/api/calendar/month&#39;,
           data:{
            &#39;year-month&#39;:yearMonth
           },
           success(data){
               resolve(data)
           },
           error(err){
               reject(err)
           }
       });
    });

   }


   function getYearData(year){
    return new Promise((resolve,reject)=&gt;{
       axiosPost({
           url: &#39;/api/calendar/year&#39;,
           data:{year},
           success(data){
               resolve(data)
           },
           error(err){
               reject(err)
           }
       });
    });

   }

   export {
    getDayData,
    getMonthData,
    getYearData 
   }</code></pre><h3 id="封装getData函数"><a href="#封装getData函数" class="headerlink" title="封装getData函数"></a>封装getData函数</h3><pre><code>export default async (store,field, date) =&gt; {
  let data = null;
  switch (field) {
    case &quot;day&quot;:
      data = await getDayData(date);
      break;
    case &quot;month&quot;:
      data = await getMonthData(date);
      break;
    case &quot;year&quot;:
      data = await getYearData(date);
      break;
    default:
      break;

  }


  if (data.error_code !== 0) {
    store.commit (&#39;setErrorCode&#39;, data.error_code);
    return;
  }

  let res = null;

  switch(field){
    case &#39;day&#39;:
      res = data.result.data;

      res.date =  formathChsDate(res.date,&#39;day&#39;);
      res[&#39;year-month&#39;] = formathChsDate(res[&#39;year-month&#39;],&#39;month&#39;);
      break;
      case &#39;month&#39;:
       res = data.result.data.holiday_array;
       res = mapForChsDate(res, &#39;festival&#39;);
       break;
       case &#39;year&#39;:
         res = data.result.data.holiday_list;
         res = mapForChsDate(res,&#39;startday&#39;)
  }</code></pre><p>通过这一列操作后成功把state的data值进行赋值然后操作computed获取到的值传入子组件data中 然后在子组件通过 props{data:Object}就可以操作data值进行修改 </p>
<pre><code>&lt;template&gt;
  &lt;div class=&quot;card-wrapper&quot;&gt;
      &lt;div class=&quot;card&quot;&gt;
          &lt;div class=&quot;header&quot;&gt;
           &lt;span class=&quot;weekday&quot;&gt;{{data.weekday}}&lt;/span&gt;
            &lt;h1 class=&quot;text lunar&quot;&gt;{{data.lunar}}&lt;/h1&gt; 
            &lt;h2 class=&quot;text date&quot;&gt;{{data.date}}&lt;/h2&gt;

          &lt;/div&gt;

      &lt;/div&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
name: &#39;DayCard&#39;,
props: {
 data:Object,
}

}
&lt;/script&gt;</code></pre><pre><code>&lt;template&gt;
  &lt;div class=&quot;day-list&quot;&gt;
      &lt;item-list
      title=&quot;当前年份&quot;
      :content=&quot;data[&#39;year-month&#39;]&quot;
      /&gt;
    &lt;item-list
      title=&quot;今年属相&quot;
      :content= &quot;data.animalsYear&quot;
      /&gt;
       &lt;item-list
      title= &quot;农历年份&quot;
      :content= &quot;data.lunar&quot;
      /&gt;
       &lt;item-list
      title= &quot;适宜事件&quot;
      :content= &quot;data.suit&quot;
      /&gt;
       &lt;item-list
      title= &quot;避免事件&quot;
      :content= &quot;data.avoid&quot;
      /&gt;  

  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import itemList from &#39;./item&#39;
export default {
    name: &#39;DayList&#39;,
    props:{
    data:Object
    },
    components:{
        itemList
    }

}
&lt;/script&gt;

&lt;style&gt;

&lt;/style&gt;</code></pre><p>到这里day基本完成</p>
<h2 id="month页面"><a href="#month页面" class="headerlink" title="month页面"></a>month页面</h2><p>month页面 也是类似进行子组件导入 因为涉及方法不一样这里通过 monthData进行接收。</p>
<pre><code>&lt;template&gt;
  &lt;div class=&quot;contaniner&quot;&gt;

    &lt;error-tip/&gt;
    &lt;div v-if=&quot;!errorCode&quot;&gt;
      &lt;month-list :data=&quot;monthData&quot;&gt;&lt;/month-list&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/template&gt;

&lt;script&gt;

import MonthList from &#39;@/components/MonthDage/List&#39;;
import ErrorTip from &#39;@/components/ErrorTip/ComErr&#39;;

import { onMounted, computed} from &#39;vue&#39;;
import {getNowDate} from &#39;@/libs/utils&#39;
import getData from &#39;@/services&#39; 
import { useStore } from &#39;vuex&#39;;

export default {
   name: &#39;MonthPage&#39;,
   components:{
      MonthList,
      ErrorTip
   },

  setup(){
     const store = useStore(),
            state = store.state;

  onMounted(()=&gt;{
    getData(store,&#39;month&#39;,getNowDate(&#39;month&#39;))
  });

  return {
    monthData:computed(()=&gt;state.monthData),
   errorCode: computed(()=&gt;state.errorCode) 
  }

}


}
&lt;/script&gt;

&lt;style&gt;

&lt;/style&gt;</code></pre><h3 id="month-list（父组件）"><a href="#month-list（父组件）" class="headerlink" title="month-list（父组件）"></a>month-list（父组件）</h3><pre><code>&lt;template&gt;
  &lt;div class=&quot;holiday-list&quot;&gt;
     &lt;ul class=&quot;holiday-list&quot;&gt;
 &lt;card-item
    v-for=&quot;(item,index) of data&quot;
    :key =&quot;index&quot;
    :item=&quot;item&quot;
      /&gt;
     &lt;/ul&gt;


  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import CardItem from &quot;./item&quot;;
export default {
  name: &quot;ListData&quot;,
  components: {
    CardItem,
  },
  props: {
    data: Array,
  },
};
&lt;/script&gt;

&lt;style&gt;
&lt;/style&gt;</code></pre><h4 id="month-item-孙组件"><a href="#month-item-孙组件" class="headerlink" title="month-item(孙组件)"></a>month-item(孙组件)</h4><pre><code>&lt;template&gt;
  &lt;div class=&quot;card-item&quot;&gt;
    &lt;div class=&quot;card&quot;&gt;
      &lt;div class=&quot;img-wrap&quot;&gt;
        &lt;img :src=&quot;require(`../../assets/img/${item.name}.jpg`)&quot; alt /&gt;
        &lt;div class=&quot;mask&quot;&gt;
          &lt;h1&gt;{{ item.name}}&lt;/h1&gt;
          &lt;h2&gt;{{item.festival}}&lt;/h2&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;content-wrap&quot;&gt;
        &lt;h1&gt;假期描述：{{item.desc || '无说明'}}&lt;/h1&gt;
        &lt;h2&gt;拼假建议：{{item.rest || '无说明'}}&lt;/h2&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  name: &quot;CardItem&quot;,
  props: {
    item: Object,
  },

  setup() {},
};
&lt;/script&gt;
</code></pre><h2 id="year页面"><a href="#year页面" class="headerlink" title="year页面"></a>year页面</h2><p>然后就是year页面通过的思路就不用多说了</p>
<pre><code>&lt;template&gt;
  &lt;div class=&quot;list-wrapper&quot; &gt;
      &lt;ul class=&quot;holiday-list&quot;&gt;
        &lt;card-item
         v-for=&quot;(item,index) of data&quot;
         :key=&quot;index&quot;
         :item=&quot;item&quot;
        /&gt;    
      &lt;/ul&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import CardItem from &#39;./Yearitem&#39;
export default {
    name: &#39;CardList&#39;,
    props:{
        data: Array
    },
    components:{
        CardItem 
    }

}
&lt;/script&gt;

&lt;style&gt;

&lt;/style&gt;</code></pre><pre><code>&lt;template&gt;
  &lt;div class=&quot;card-item&quot;&gt;
      &lt;div class=&quot;card&quot;&gt;
          &lt;div class=&quot;img-wrap&quot;&gt;
         &lt;img :src=&quot;require(`../../assets/img/${item.name}.jpg`)&quot; alt=&quot;&quot;/&gt;
         &lt;div class=&quot;mask&quot;&gt;
            &lt;h1&gt;{{item.name}}&lt;/h1&gt;
            &lt;h2&gt;{{item.startday}}&lt;/h2&gt;
         &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;

  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
    name:&#39;CardItem&#39;,
    props:{
        item:Object
    }

}
&lt;/script&gt;</code></pre><p>到了这里页面切换以及组件基本完成，</p>
<h2 id="状态码处理懒加载"><a href="#状态码处理懒加载" class="headerlink" title="状态码处理懒加载"></a>状态码处理懒加载</h2><p>还有一些细节比如说请求不到数据需要进行图片懒加载仓库新建  errorCode: 0,用于存放状态码的还有setErrorCode方法  然后导入文件单独封装状态码的</p>
<pre><code>export default {
    &quot;217701&quot;: &quot;未搜索到数据&quot;,
    &quot;217702&quot;: &quot;输入的日期格式错误&quot;,
    &quot;10001&quot;: &quot;无请求权限&quot;,
    &quot;10002&quot;: &quot;无请求权限&quot;,
    &quot;10003&quot;: &quot;无请求权限&quot;,
    &quot;10004&quot;: &quot;无请求权限&quot;,
    &quot;10005&quot;: &quot;无请求权限&quot;,
    &quot;10007&quot;: &quot;未知的请求源&quot;,
    &quot;10008&quot;: &quot;IP被禁止使用该功能&quot;,
    &quot;10009&quot;: &quot;无请求权限&quot;,
    &quot;10011&quot;: &quot;超过搜索数据限制次数&quot;,
    &quot;10012&quot;: &quot;超过搜索数据限制次数&quot;,
    &quot;10013&quot;: &quot;超过搜索数据限制次数&quot;,
    &quot;10014&quot;: &quot;系统正在维护&quot;,
    &quot;10020&quot;: &quot;系统正在维护&quot;,
    &quot;10021&quot;: &quot;系统正在维护&quot;,
  };</code></pre><p>封装一个ErrorTip单独处理失败状态码的</p>
<pre><code>&lt;template&gt;
  &lt;div class=&quot;error-tip&quot; v-if=&quot;errorCode&quot;&gt;
      &lt;img :src=&quot;require(&#39;../../assets/img/error.png&#39;)&quot;&gt;
      &lt;p&gt;{{ errorData[errorCode]}}&lt;/p&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import errorData from &#39;@/data/error&#39;
import { useStore } from &#39;vuex&#39;
import { computed } from &#39;vue&#39;;

export default {
    name: &#39;ErrorTip&#39;,
    setup(){
        const store = useStore(),
               state = store.state;
     return {
         errorCode: computed(()=&gt;state.errorCode),
         errorData
     }
    }

}
&lt;/script&gt;
</code></pre><p>然后在合适的位置导入进去 通过v-if判断组件是否显示 判断的依据自然就是errorCode</p>
<pre><code>  &lt;error-tip/&gt;
    &lt;div v-if=&quot;!errorCode&quot;&gt;
      &lt;month-list :data=&quot;monthData&quot;&gt;&lt;/month-list&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre><pre><code>   &lt;error-tip/&gt;
    &lt;div v-if=&quot;!errorCode&quot;&gt;
       &lt;card-list :data=&quot;yearData&quot;/&gt;
    &lt;/div&gt;</code></pre><p>图片懒加载也完成了，接下来完成input输入进行数据改变 先通过 <code>@input=&quot;searchData($event)&quot;</code>绑定点击事件 然后对事件进行处理传入参数e可以通过 e.target.value监听到用户输入的值 这里需要定义一个变量因为vue3是通过ref定义的</p>
<p><code>const inputValue = ref(&#39;&#39;),</code></p>
<pre><code> const searchData = (e) =&gt;{
        //获取用户输入的值 
        inputValue.value = e.target.value;
        //获取state仓库数据 field默认的day值
        const field = computed(()=&gt;state.field).value;

     //当用户输入的值为和限定的输入的maxlength相等
    if(inputValue.value.length == props.maxlength ){
      //  console.log(props.maxlength);
      //这里是监听用户输入的值工具函数将用户输入的20200616转换为接口需要的2020-6-16
      getData(store,field,formatUserDate(inputValue.value));

    }else if( inputValue.value.length === 0){
      getData(store,field,getNowDate(field))
    }
      }</code></pre><h2 id="formatUserDate（）函数"><a href="#formatUserDate（）函数" class="headerlink" title="formatUserDate（）函数"></a>formatUserDate（）函数</h2><p>这里用到一个工具函数</p>
<pre><code>//处理用户输入的日期进行转换
function formatUserDate(value) {
  const len = value.length;

  if (len &lt; 4) {
  //不满足4位取空
    return;
  }

  if (len === 4) {
  //满足2020 4位直接返回
    return value;
  }

  if (len &gt; 4 &amp;&amp; len &lt; 6) {

    return value.substr(0, 4);
    //截取值前4位
  }

  let _arr = [],
    pattern;

  if (len &gt;= 6 &amp;&amp; len &lt; 8) {
    pattern = /(\d{4})(\d{2})/;
    value = value.substr(0, 6).replace(pattern, &quot;$1-$2&quot;);

    _arr = Array.from(value).filter((item, index) =&gt; {
      if (index === 5 &amp;&amp; item === &quot;0&quot;) {
        return false;
      }
      return true;
    });
  }

  if (len &gt;= 8) {
    pattern = /(\d{4})(\d{2})(\d{2})/;
    value = value.substr(0, 8).replace(pattern, &quot;$1-$2-$3&quot;);

    _arr = Array.from(value).filter((item, index) =&gt; {
      if ((index === 5 || index === 8) &amp;&amp; item === &quot;0&quot;) {
        return false;
      }
      return true;
    });
  }

  return _arr.toString().replace(/,/g, &quot;&quot;);
}</code></pre><p>处理好了输入框输入内容会被监听到和长度判断 为什么要长度判断是应该我们在day要输入20200616然后月202006 然后是 2020然后进行判断赋值 然后完成后发现每次切换回来数据会保存所以通过watch进行数据清除</p>
<pre><code>  watch(()=&gt;{
      return state.field;
    },()=&gt;{
      inputValue.value = &#39;&#39;;
    })</code></pre><p>到这里万年历项目完成</p>
<h2 id="总计经验"><a href="#总计经验" class="headerlink" title="总计经验"></a>总计经验</h2><p>vue3.0使用了组合式api Compositions 使用了按需加载，使得代码更轻便。操作store很方便有点类似react的hook，通过学习这个项目对组件化思想更加清晰，代码复用性强很多。就比如错误代码组件，一些共用型强的组件都可以直接使用。代码更加简洁，使用了解决跨域问题的数据代理。通过代理模拟服务器向服务器发送请求不会被同源策略拦截。封装接口层层封装代码管理起来也更加方便了。体验还是不错的</p>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/zheng_jinhao/about" rel="external nofollow noreferrer">小蛮牙</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://zheng_jinhao.gitee.io/zheng_jinhao/2020/08/07/vue3-0-xiang-mu/">https://zheng_jinhao.gitee.io/zheng_jinhao/2020/08/07/vue3-0-xiang-mu/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/zheng_jinhao/about" target="_blank">小蛮牙</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/zheng_jinhao/tags/vue/">
                                    <span class="chip bg-color">vue</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/zheng_jinhao/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/zheng_jinhao/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的支持是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1//medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1//medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments textarea {
        box-sizing: border-box;
        background: url("/zheng_jinhao/medias/comment_bg.png") 100% 100% no-repeat;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #4cbf30;
        font-weight: 500;
        text-decoration: none;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="vcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/zheng_jinhao/libs/valine/av-min.js"></script>
<script src="/zheng_jinhao/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'fIVm2ru0g1QdmBiHbb0VyPag-gzGzoHsz',
        appKey: 'gp3czLg0Lm6yE1fzOACGaLsH',
        notify: 'false' === 'true',
        verify: 'false' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: 'just go go'
    });
</script>

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/zheng_jinhao/2020/08/16/js-ji-chu-zheng-li/">
                    <div class="card-image">
                        
                        
                        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn//medias/featureimages/2.jpg" class="responsive-img" alt="js-基础整理">
                        
                        <span class="card-title">js-基础整理</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            js基本数据类型：string number boolean null underfined  （Es6) Symbol
复杂类型：Oject(对象) funtion(函数）涉及到很多API分开整理
常见的语句：1.switch () ca
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-08-16
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/zheng_jinhao/categories/javascript%E7%AF%87/" class="post-category">
                                    javascript篇
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/zheng_jinhao/tags/javaScript/">
                        <span class="chip bg-color">javaScript</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/zheng_jinhao/2020/08/01/vue-bi-ji/">
                    <div class="card-image">
                        
                        
                        <img src="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn@1.1/images/lading.gif" data-original="https://cdn.jsdelivr.net/gh/lucy-zheng123/cdn//medias/featureimages/5.jpg" class="responsive-img" alt="vue笔记">
                        
                        <span class="card-title">vue笔记</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            vue3 新特性安装3.0版本
npm install -g @vue/cli
安装的时候遇到问题
 我的脚手架之前是安装4.3.1可以安装vue3但是有一些特性使用不了。只好升级4.4.1版本。然后在输入卸载指令的时候   npm uni
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-08-01
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/zheng_jinhao/categories/vue/" class="post-category">
                                    vue
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/zheng_jinhao/tags/vue/">
                        <span class="chip bg-color">vue</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/zheng_jinhao/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/zheng_jinhao/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/zheng_jinhao/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/zheng_jinhao/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/zheng_jinhao/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/zheng_jinhao/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="2195404116"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='false'
        >
        </meting-js>
    </div>
</div>

<script src="/zheng_jinhao/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="/zheng_jinhao/about" target="_blank">小蛮牙</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">56.7k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/lucy-zheng123" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:766557057@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=766557057" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 766557057" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/zheng_jinhao/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>



    
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/zheng_jinhao/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/zheng_jinhao/search.xml", 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/zheng_jinhao/libs/materialize/materialize.min.js"></script>
    <script src="/zheng_jinhao/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/zheng_jinhao/libs/aos/aos.js"></script>
    <script src="/zheng_jinhao/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/zheng_jinhao/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/zheng_jinhao/js/matery.js"></script>

    <!--单击显示文字-->

<!--浏览器搞笑标题-->
<!-- <script type="text/javascript" src="\js\FunnyTitle.js"></script> -->








<!--动态线条背景-->
<script type="text/javascript"
color="220,220,220" opacity='0.7' zIndex="-2" count="200" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js">
</script>
<!-- 雪花特效 -->
<!-- <script type="text/javascript" src="\js\snow.js"></script> -->
<!-- <script src="https://cj.weather.com.cn"></script> -->

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/zheng_jinhao/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/zheng_jinhao/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    

    
    <script src="/zheng_jinhao/libs/instantpage/instantpage.js" type="module"></script>
    

<script src="/zheng_jinhao/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/zheng_jinhao/live2dw/assets/z16.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"left","hOffset":0,"vOffset":-20},"mobile":{"show":false,"scale":0.5},"log":false});</script><script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(n){n.imageLazyLoadSetting.processImages=o;var i=n.imageLazyLoadSetting.isSPA,r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]"));function o(){i&&(r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")));for(var t,e,a=0;a<r.length;a++)t=r[a],e=void 0,0<=(e=t.getBoundingClientRect()).bottom&&0<=e.left&&e.top<=(n.innerHeight+240||document.documentElement.clientHeight+240)&&function(){var t,e,n,i,o=r[a];t=o,e=function(){r=r.filter(function(t){return o!==t})},n=new Image,i=t.getAttribute("data-original"),n.onload=function(){t.src=i,e&&e()},n.src=i}()}o(),n.addEventListener("scroll",function(){var t,e;t=o,e=n,clearTimeout(t.tId),t.tId=setTimeout(function(){t.call(e)},500)})}(this);</script></body>

</html>
